<%@ page contentType="text/html; charset=UTF-8" session = "true"%>
<%@page import="java.io.File"%>
<%@page import="java.util.Date"%>
<%@page import="java.util.GregorianCalendar"%>
<%@page import="java.util.Iterator"%>
<%@page import="java.util.List"%>
<%@include file = "cargarLogica.jsp" %>

<!DOCTYPE html>
<html lang="es">
    
<head>
	<title>TPlay Market - Registrar</title>
	<meta name="description" content="Bienvenido a TPlay Market, tienda de Juegos On-Line"/>
	<meta name="viewport" content="width=device-width, initial-scale=1"/>
	<link rel="shortcut icon" type="image/xicon" href="favicon.ico"/>
	<link rel="stylesheet" type="text/css" href="css/tplay_style.css"/>
        <link rel="stylesheet" type="text/css" href="css/JF_S/registrar.css"/>
        <script type = "text/javascript" src = "js/JQuery2.0.3.js"></script>
        <script type = "text/javascript" src = "js/JF_JS/registrar.js"></script>
        <script type = "text/javascript">
            
        <%

            if(iw != null){

        %>
                                                
        <%
              
            if(session.getAttribute("usuario") == null){

                try{

                    List<String> listaNicks = ip.getNicks();
                    Iterator<String> it = listaNicks.iterator();

                    while(it.hasNext()){

                        String nick = it.next();
                        %>

                        listaNicks[listaNicks.length] = "<%=nick%>";

                        <%

                    }

                }

                catch(Exception e){

                    session.setAttribute("error", e.getMessage());
                    response.sendRedirect("error.jsp");

                }

                try{

                    List<String> listaEmails = ip.getEmails();
                    Iterator<String> it = listaEmails.iterator();

                    while(it.hasNext()){

                        String email = it.next();
                        %>

                        listaEmails[listaEmails.length] = "<%=email%>";

                        <%

                    }

                }

                catch(Exception e){

                    session.setAttribute("error", e.getMessage());
                    response.sendRedirect("error.jsp");

                }

            }
            
            else{
            
                response.sendRedirect("/TPlay_Market_Web");
            
            }
        
        %>
    
        </script>
<body>
            
        <jsp:include page="tplay_header.jsp"/>
        <jsp:include page="tplay_nav_visitante.jsp"/>
                
	<section id="contenido">
            <form id = "F_Registrar" name = "F_Registrar" action = "registrarAP.jsp" method = "POST" enctype="MULTIPART/FORM-DATA" onsubmit = "return validarForm();"><br>
                    <label id = "LBL_Estado">Ingrese sus datos</label><br><br>
                    <div id = "DIV_1" class = "etiquetas divisiones">
                        <div id = "DIV_Nick" class = "etiquetas">Nick: <br><input id = "TF_Nick" class = "campos" type = "text" name = "TF_Nick" required = "required"/><img id = "IMG_Nick"/></div>
                        <div id = "DIV_Email" class = "etiquetas">Email: <input id = "TF_Email" class = "campos" type = "email" name = "TF_Email" required = "required"/><img id = "IMG_Email"/></div>
                        <div id = "DIV_Password" class = "etiquetas">Contraseña: <input id = "TF_Password" class = "campos" type = "password" name = "TF_Password" required = "required"/><label id = "LBL_Nivel">Nulo</label></div>
                        <div id = "DIV_Confirmar" class = "etiquetas">Confirmar: <input id = "TF_Confirmar" class = "campos" type = "password" name = "TF_Confirmar" required = "required"/><img id = "IMG_Password"/></div>
                        <div id = "DIV_Tipo" class = "etiquetas">Tipo de Perfil:<br>
                            <select id = "S_Tipo" name = "S_Tipo" class = "fvalores" onchange = "cargarWeb();">
                                <option value = "[CLIENTE]">Cliente</option>
                                <option value = "[DESARROLLADOR]">Desarrollador</option>
                        </select></div>
                        <div id = "DIV_Nombre" class = "etiquetas">Nombre: <input id = "TF_Nombre" class = "campos" type = "text" name = "TF_Nombre" required = "required"/></div>
                        <div id = "DIV_Apellido" class = "etiquetas">Apellido: <input id = "TF_Apellido" class = "campos" type = "text" name = "TF_Apellido" required = "required"/></div>
                        <div id = "DIV_FNac" class = "etiquetas">Fecha de Nacimiento:<br>
                            <select id = "S_Dia" name = "S_Dia" class = "fvalores">
                                <%

                                    String dias = new String("<option value = \"DIA\">Día</option>");

                                    for(int i = 31; i > 0; i--){

                                        dias = dias.concat("<option value = " + i + ">" + i + "</option>");

                                    }

                                %>
                                <%=dias%>
                            </select>
                            <select id = "S_Mes" name = "S_Mes" class = "fvalores">
                                <option value = "MES">Mes</option>
                                <option value = "1">Enero</option>
                                <option value = "2">Febrero</option>
                                <option value = "3">Marzo</option>
                                <option value = "4">Abril</option>
                                <option value = "5">Mayo</option>
                                <option value = "6">Junio</option>
                                <option value = "7">Julio</option>
                                <option value = "8">Agosto</option>
                                <option value = "9">Septiembre</option>
                                <option value = "10">Octubre</option>
                                <option value = "11">Noviembre</option>
                                <option value = "12">Diciembre</option>
                            </select>
                            <select id = "S_Year" name = "S_Year" class = "fvalores">
                                <%

                                    GregorianCalendar gc = new GregorianCalendar();
                                    gc.setTime(new Date());

                                    Integer minaño = gc.get(GregorianCalendar.YEAR);
                                    minaño = minaño - 120;

                                    Integer maxaño = gc.get(GregorianCalendar.YEAR);

                                    String años = new String("<option value = \"YEAR\">Año</option>");

                                    for(int i = maxaño; i > minaño; i--){

                                        años = años.concat("<option value = " + i + ">" + i + "</option>");

                                    }

                                %>
                                <%=años%>
                            </select>
                        </div>
                        <div id = "DIV_Web" class = "etiquetas">WebSite: <input id = "TF_Web" disabled class = "campos" type = "text" name = "TF_Web" required = "required"/></div>
                    </div>
                    <div id = "DIV_2" class = "etiquetas">
                        <input id = "I_Archivos" name = "I_Archivos" type = "file" accept = "image/*" required = "required"/><br><br>
                        <img id = "IMG_Imagen" src = "img/perfilPredeterminada3.png"/><br><br>                       
                        <button id = "BTN_Confirmar" class = "botones" type = "submit">Confirmar</button>
                    </div>
                </form>
	</section>
                     
        <%
    
            }
        
        %>
                            
        <jsp:include page="tplay_footer.jsp"/>
                                        
</body>
</html>